package com.ys.erp.entity.data.bean;

import com.alibaba.fastjson2.JSONArray;
import com.baomidou.mybatisplus.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author lwj
 * @date 2023/4/16
 */

@Data
@TableName(value = "t_goods")
@Accessors(chain = true)
public class Goods {

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 商品类型
     */
    @TableField("goods_type")
    private Integer goodsType;

    /**
     * 宠物类型
     */
    @TableField("pet_type")
    private String petType;


    /**
     * 是否展示使用标签
     */
    @TableField("is_use_tag")
    private Integer isUseTag;

    /**
     * 商品标签
     */
    @TableField("goods_tag")
    private String goodsTag;


    /**
     * 分类id
     */
    @TableField(value = "category_id")
    private Long categoryId;

    @TableField(value = "brand_id")
    private Long brandId;

    /**
     * 商品名称
     */
    @TableField(value = "goods_name")
    private String goodsName;

    /**
     * 商品标题
     */
    @TableField(value = "goods_title")
    private String goodsTitle;

    /**
     * 商品banner
     */
    @TableField(value = "goods_banner")
    private String goodsBanner;

    /**
     * 商品视频
     */
    @TableField(value = "goods_video")
    private String goodsVideo;

    /**
     * 是否上架
     */
    @TableField(value = "is_line")
    private Integer isLine;

    /**
     * 上架时间
     */
    @TableField(value = "line_time")
    private LocalDateTime lineTime;


    @TableField(value = "is_auto_send_goods")
    private Integer isAutoSendGoods;

    /**
     * 排序
     */
    @TableField(value = "order_num")
    private Integer orderNum;

    /**
     * 商品价格（单位：分）
     */
    @TableField(value = "goods_price")
    private Long goodsPrice;

    @TableField(value = "ys_money")
    private Long ysMoney;

    @TableField(value = "ys_money_describe")
    private String ysMoneyDescribe;

    /**
     * 划线价格（分）
     */
    @TableField(value = "scribe_price")
    private Long scribePrice;

    /**
     * 单位
     */
    @TableField(value = "goods_unit")
    private String goodsUnit;

    /**
     * 成本价格（分）
     */
    @TableField(value = "cost_price")
    private Long costPrice;

    @TableField(value = "stock_total")
    private Long stockTotal;

    @TableField(value = "goods_weight")
    private Integer goodsWeight;

    /**
     * 规格json
     */
    @TableField(value = "attr_list")
    private String attrList;

    /**
     * 已售数量
     */
    @TableField(value = "sale_num")
    private Integer saleNum;

    @TableField(value = "real_sale_num")
    private Integer realSaleNum;

    @TableField(value = "delivery_type")
    private String deliveryType;

    /**
     * 是否限购0否1是
     */
    @TableField(value = "is_quota")
    private Integer isQuota;

    /**
     * 终生限购数量 0：无限制
     */
    @TableField(value = "life_quota_num")
    private Integer lifeQuotaNum;

    /**
     * 订单限购数量
     */
    @TableField(value = "order_quota_num")
    private Integer orderQuotaNum;

    /**
     * 周期限购，json格式，key: 0 每天 1 每周 2 每月 3 每年，v：限购数量
     */
    @TableField(value = "cycle_quota_num")
    private String cycleQuotaNum;

    /**
     * 是否开启限制浏览购买权限
     */
    @TableField(value = "is_show_buy_right")
    private Integer isShowBuyRight;

    /**
     * json, 会员浏览权限
     */
    @TableField(value = "show_grade_id")
    private String showGradeId;

    /**
     * json，会员购买权限
     */
    @TableField(value = "quota_grade_id")
    private String quotaGradeId;

    @TableField(value = "city_name_list")
    private String cityNameList;

    /**
     * 领猫天数
     */
    @TableField(value = "adopt_cat_days")
    private Integer adoptCatDays;

    /**
     *领猫超过多少天浏览
     */
    @TableField(value = "adopt_cat_days_view")
    private Integer adoptCatDaysView;

    /**
     * 运费id
     */
    @TableField(value = "freight_id")
    private Long freightId;

    /**
     * 是否包邮0否1是
     */
    @TableField(value = "is_cost")
    private Integer isCost;

    /**
     * 包邮id
     */
    @TableField(value = "cost_id")
    private Long costId;

    /**
     * 是否开启区域限购
     */
    @TableField(value = "is_area_quota")
    private Integer isAreaQuota;

    /**
     * json，限购区域
     */
    @TableField(value = "quota_area")
    private String quotaArea;

    /**
     * 分享title
     */
    @TableField(value = "share_title")
    private String shareTitle;

    /**
     * 自定义分享图片
     */
    @TableField(value = "share_pic")
    private String sharePic;

    /**
     * 商品详情
     */
    @TableField(value = "goods_detail")
    private String goodsDetail;

    /**
     * 是否删除
     */
    @TableField(value = "is_delete")
    private Integer isDelete;

    @TableField("is_cash")
    private Integer isCash;

    @TableField("is_repeat")
    private Integer isRepeat;

    @TableField(value = "version")
    @Version
    private Integer version;

    @TableField(value = "create_time")
    private LocalDateTime createTime;

    @TableField(value = "update_time", update = "now()")
    private LocalDateTime updateTime;

    @Data
    public static class GoodsAttrValues {

        //值
        private String value;

    }

    @Data
    public static class CardGoodsDTO {

        private Long cardId;

        private String cardName;

        private Integer cardNum;
    }

    @AllArgsConstructor
    @Getter
    public enum Enums {

        ;
    }

    public static final Map<String, String> ENUM_MAP = new HashMap<>();

    static {

    }

    public static boolean isContainsKey(String key) {
        return ENUM_MAP.containsKey(key);
    }
    public List<String> getGoodsBannerList() {
        return JSONArray.parseArray(this.goodsBanner, String.class);
    }
}